//
//  SliderBoot.swift
//  SwiftUIWidgetDemo
//
//  Created by alanzhangg on 2023/7/17.
//

import SwiftUI

struct SliderBoot: View {
    
    @State var sliderNumber: Double = 3
    @State private var isEditing = false
    
    var body: some View {
        VStack {
            
            Text(String(format: "%.1f", sliderNumber))
            
            Slider(value: $sliderNumber, in: 0...100)
                .padding()
            .accentColor(.red)
            
            Slider(value: $sliderNumber, in: 0...5, step: 2.0)
                .accentColor(.red)
            Slider(value: $sliderNumber, in: 1...100, step: 10) {
                Text("title")
            } minimumValueLabel: {
                Text("0")
            } maximumValueLabel: {
                Text("100")
            } onEditingChanged: { edit in
                isEditing = edit
            }
            
            Text("speed")
                        .foregroundColor(isEditing ? .red : .blue)
            
        }
    }
}

#Preview {
    SliderBoot()
}
